#ifndef __MCSC__LEXER__HPP
#define __MCSC__LEXER__HPP

#ifndef yyFlexLexer
#include <FlexLexer.h>
#endif //yyFlexLexer

#include "ParserDefines.hpp"
#include "Preprocessor.hpp"

class Lexer : public yyFlexLexer
{
public:
	Lexer(InputStream * stream);
	~Lexer();

	int yylex(yy::parser::semantic_type * llvap, yy::parser::location_type * llocp)
	{
		int retVal = Lexer::yylex();
		if(llvap) *llvap = yylval;
		if(llocp) *llocp = yylloc;
		return retVal;
	}
	
	virtual int yylex();
protected:
	virtual int LexerInput( char* buf, int max_size );
	virtual void LexerError( const char* msg );
private:
	yy::parser::semantic_type yylval;
	yy::parser::location_type yylloc;
	SourcePosition position_;
	Preprocessor preprocessor_;

	void prepareForAction();

	static String unescape(char const * str);
	static int parseInt(char const * str, int base);
	static double parseReal(char const * str);
};

#endif //__MCSC__LEXER__HPP